Namespace definitions

Cryptographic functions.

Since

0.10.6

Functions

Link copied to clipboard
function eth_ecrecover(r: byte_array, s: byte_array, rec_id: integer, data_hash: byte_array): byte_array

Calculates an Ethereum public key from a signature and hash.

Link copied to clipboard

Derives a 20-byte Ethereum address from a 32-byte private key.

Link copied to clipboard

Derives a 20-byte Ethereum address from a public key (33, 64, or 65 bytes).

Link copied to clipboard
function eth_sign(data_hash: byte_array, privkey: byte_array): (byte_array, byte_array, integer)

Calculates an Ethereum signature. Takes a hash and a private key and returns values r, s, and rec_id that are accepted by eth_ecrecover.

Link copied to clipboard
function get_signature(data_hash: byte_array, privkey: byte_array): byte_array

Calculates a ECDSA (secp256k1) signature. The returned value can be verified with the verify_signature() function.

Link copied to clipboard
function keccak256(input: byte_array): byte_array

Calculates a Keccak256 hash of a byte array and returns a byte array.

Link copied to clipboard
function privkey_to_pubkey(privkey: byte_array, compressed: boolean): byte_array

Converts a privkey to a pubkey

Link copied to clipboard
function pubkey_encode(pubkey: byte_array, compressed: boolean): byte_array

Converts a public key between compressed (33-byte) and uncompressed (65-byte) formats.

Link copied to clipboard

Extracts the EC point coordinates (x, y) from a public key.

Link copied to clipboard
function sha256(input: byte_array): byte_array

Calculates an SHA-256 hash of a byte array and returns a byte array.

Link copied to clipboard
function verify_signature(data_hash: byte_array, pubkey: byte_array, signature: byte_array): boolean

Verifies a signature against a message and public key.

Link copied to clipboard
function xy_to_pubkey(x: big_integer, y: big_integer, compressed: boolean): byte_array

Constructs a public key (compressed or uncompressed) from EC point coordinates.